package com.atwisdom.star.core.dao.service.modelClass.consume.Impl;

import com.atwisdom.star.core.dao.mapper.modelClass.ConsumeInstanceMapper;
import com.atwisdom.star.core.dao.pojo.modelClass.consume.ConsumeInstance;
import com.atwisdom.star.core.dao.service.modelClass.consume.ConsumeInstanceService;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

/**
* @author fushb
* @description 针对表【consume_instance】的数据库操作Service实现
* @createDate 2023-03-30 14:27:39
*/
@Service
public class ConsumeInstanceServiceImpl extends ServiceImpl<ConsumeInstanceMapper, ConsumeInstance>
    implements ConsumeInstanceService {
    @Override
    public int realDelete(QueryWrapper wrapper){
        return this.baseMapper.realDelete(wrapper);
    }

    /**
     * 同步更新实例类名称
     * @param type 原类名
     * @param className 原类名
     * @param oldType 原类名
     * @param oldClassName 新类名
     * @return 返回结果
     */
    @Override
    public int updateClassName(String type,String className,String oldType,String oldClassName ) {
        QueryWrapper<ConsumeInstance> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("className", oldClassName);
        queryWrapper.eq("type", oldType);
        queryWrapper.eq("published", true);
        ConsumeInstance instance = new ConsumeInstance();
        instance.setClassName(className);
        instance.setType(type);
        return this.baseMapper.update(instance, queryWrapper);
    }
}




